import { createSlice } from "@reduxjs/toolkit"
import { log } from '../../configs/common'

const loginStateSlice = createSlice({
  name: 'loginState',
  initialState: {
      loading: false,
      isCertificates: false,
      show: true,
  },
  reducers: {
    // 将loading改为正在加载状态
    reqset: (state, action) => {
      log('loginState: reqset')
      return { ...state, loading: true }
    },
    // 在loginState中保存相应结果， 将加载状态改为取消
    receive: (state, action) => {
      log('loginState: receive')
      const {req, res} = action.payload
      return { data: res, loading: false }
    },
    loading: (state, action) => {
      log('logingState: reject')
      return{
        ...state,
        loading: action.payload.loading
      }
    }
  }
})

export const { reqset, receive, loading } = loginStateSlice.actions


export default loginStateSlice.reducer





